#ifndef PROTOCOL_H
#define PROTOCOL_H

#include <string>

class TCPClient;

namespace CSProtocol
{
  class Header
  {
  public:
    int code;
    unsigned int id;
    unsigned int timestamp;
    unsigned short dataLength;
    bool spontaneous;
    bool fill;
  };

  class IData
  {
  public:

    virtual void sendTreat(TCPClient &connexion) = 0;
    virtual void receiveTreat(TCPClient &connexion, IData *data) = 0;
  };

  class Welcome : public IData
  {
  public:
    static int code;

    virtual void sendTreat(TCPClient &connexion);
    virtual void receiveTreat(TCPClient &connexion, IData *data);
  };

  class Login : public IData
  {
  public:
    static int code;

    char login[64];
    char pass[64];

    virtual void sendTreat(TCPClient &connexion);
    virtual void receiveTreat(TCPClient &connexion, IData *data);
  };

  class Logout : public IData
  {
  public:
    static int code;

    virtual void sendTreat(TCPClient &connexion);
    virtual void receiveTreat(TCPClient &connexion, IData *data);

  };

  class Register : public IData
  {
  public:
    static int code;

    char login[64];
    char pass[64];
    char email[256];

    virtual void sendTreat(TCPClient &connexion);
    virtual void receiveTreat(TCPClient &connexion, IData *data);
  };

  class Profil
  {
  public:
    static const int code = 004;

    char pseudo[256];
    int age;
    char extra[1024];

    virtual void sendTreat(TCPClient &connexion);
    virtual void receiveTreat(TCPClient &connexion, IData *data);
  };

  class Password
  {
  public:
    static const int code = 005;

    char oldP[64];
    char newP[64];

    virtual void sendTreat(TCPClient &connexion);
    virtual void receiveTreat(TCPClient &connexion, IData *data);
  };

  class Email
  {
  public:
    static const int code = 006;

    char oldM[256];
    char newM[256];

    virtual void sendTreat(TCPClient &connexion);
    virtual void receiveTreat(TCPClient &connexion, IData *data);
  };

  class Status
  {
  public:
    static const int code = 007;

    char status;

    virtual void sendTreat(TCPClient &connexion);
    virtual void receiveTreat(TCPClient &connexion, IData *data);
  };

  class AddContact : public IData
  {
  public:
    static int code;

    char login[64];
    char category[256];

    virtual void sendTreat(TCPClient &connexion);
    virtual void receiveTreat(TCPClient &connexion, IData *data);
  };

  class RemoveContact : public IData
  {
  public:
    static int code;

    char login[64];

    virtual void sendTreat(TCPClient &connexion);
    virtual void receiveTreat(TCPClient &connexion, IData *data);
  };

  class ListContact : public IData
  {
  public:
    static int code;
  };

  class InfoContact : public IData
  {
  public:
    static int code;

    char login[64];
    char pseudo[256];
    char email[256];
    char extra[1024];
    char status;
    char category[256];

    virtual void sendTreat(TCPClient &connexion);
    virtual void receiveTreat(TCPClient &connexion, IData *data);
  };

  class SendCall : public IData
  {
  public:
    static const int code = 200;

    char login[64];

    virtual void sendTreat(TCPClient &connexion);
    virtual void receiveTreat(TCPClient &connexion, IData *data);
  };

  class ReceiveCall : public IData
  {
  public:
    static const int code = 201;

    char login[64];
    char ip[4];

    virtual void sendTreat(TCPClient &connexion);
    virtual void receiveTreat(TCPClient &connexion, IData *data);
  };

  class AbortCall : public IData
  {
  public:
    static const int code = 202;

    virtual void sendTreat(TCPClient &connexion);
    virtual void receiveTreat(TCPClient &connexion, IData *data);
  };

  class Ok : public IData
  {
  public:
    static int code;
    char what[1024];

    virtual void sendTreat(TCPClient &connexion) { (void)connexion; };
    virtual void receiveTreat(TCPClient &connexion, IData *data) { (void)data; (void)connexion; };
  };

  class Ko : public IData
  {
  public:
    static int code;

    char what[1024];

    virtual void sendTreat(TCPClient &connexion) { (void)connexion; };
    virtual void receiveTreat(TCPClient &connexion, IData *data) { (void)data; (void)connexion; };
  };


}

#endif
